<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>账号管理</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="/system_assets/css/bootstrap.min.css" rel="stylesheet">
	<link href="/system_assets/css/style.css" rel="stylesheet">
	<link href="/system_assets/css/font-awesome.css" rel="stylesheet">
		<link rel="stylesheet" href="/plugins/SweetAlert/sweetalert.css" />
</head>
<body>
	<div class="container-fluid">
		<div class="om-ctl-mes">
			<div class="title">
				<div class="col-xs-12"><span class="fa fa-list-ul"> 系统设置</span><b class="fa fa-caret-right"></b><i>账号管理</i></div>
			</div>
			<div class="seltemple">
				<div class="col-xs-12">
					<form class="form-inline" method="post" action="/admin_admin">
					<div class="col-xs-3 mes-group"><label>部门</label><select><option>请选择</option></select></div>
					<div class="col-xs-3 mes-search zhgl-search"><label>关键词搜索</label><input type="text" value="<?=$pKey?>" name="key" placeholder="员工姓名"><button id="search" type="button">搜索</button></div>
				</form>
				</div>
			</div>
			<div  class="mes-conttent col-xs-12">
				<table class="table admin-table">
	              <thead>
	             	<tr>
			        <th>编号</th>
			        <th>账户名</th>
			        <th>员工姓名</th>
			        <th>所在部门</th>
			        <th>员工所属角色</th>
			        <th>管理部门</th>
			        <th>操作</th>
		            </tr>
	              </thead>
	             <tbody>
	             <?foreach($tDatas as $tRow){?>
		           <tr>
		           	 <td><?=$tRow['id']?></td>
			         <td><?=$tRow['username']?></td>
                     <td><span><?=$tRow['name']?></span><small class="hiddendiv"></small></td>
			         <td><?=$tRow['department']?></td>
			         <td><?=$tRow['role']?></td>
			         <td><?=implode(',',$tRow['departments'])?></td>
			         <td>
			         	<button onclick="auth_manage(<?=$tRow['status']?>,'/admin_admin/auth?id=<?=$tRow['id']?>','/admin_admin')"><?=empty($tRow['status'])?"恢复":"冻结"?></button>
			         	<button>编辑</button>
			         	<a href="#" role="menuitem" onclick="cg_confirm_del('/admin_admin/delete?id=<?=$tRow['id']?>','/admin_admin')"><button style="color:black">删除</button></a>
			         </td>
		           </tr>
		           <?}?>
	            </tbody>
              </table>
              <?=$tShow?>
			</div>
		</div>
    </div>
        <script type="text/javascript" src="/system_assets/js/jquery.min.js"></script>
    <script type="text/javascript" src="/system_assets/js/jq.js"></script>
        <script src="/plugins/SweetAlert/sweetalert.min.js"></script>
        <script src="/js/sweetalert-dev.js"></script>
    <script>
    	$('#search').click(function(){
		$('form').submit();
		});
		function cg_confirm_del(del_url,jump_url){
		swal({
		        title: '您确定要删除吗？',
		        text:'删除之后不能恢复',
		        type: "warning",
		        showCancelButton: true,
		        confirmButtonColor: "#DD6B55",
		        confirmButtonText:'确定',
		        closeOnConfirm: false,
		        cancelButtonText:'取消'
		    },
		    function(isConfirm){
		        if(isConfirm){
		            window.obj = '';
		            $.ajax({
		                url: del_url,
		                dataType: "json",
		                async:false,
		                success: function (obj) {
		                    window.obj = obj;
		                }
		            });

		            if(window.obj.status == 1){
		                swal({title:"删除成功!", type:"success"},function(){
		                    location.href = jump_url;
		                });
		            }else{
		                swal({title:window.obj.msg, type:"error"});
		            }
		        }
		    });
		}
    </script>
	<script>
	function auth_manage(pStatus,pAuthUrl,pJumpUrl){
	    if(pStatus){
	        var tTitle = "您确定要冻结该账号吗？";
	        var tText = "冻结后该账号将无法登录后台";
	    }else{
	        var tTitle = "您确定要恢复该账号吗？";
	        var tText = "恢复后该账号即可正常登录后台";
	    }
	    swal({
	            title: tTitle,
	            text: tText,
	            type: "warning",
	            showCancelButton: true,
	            confirmButtonColor: "#DD6B55",
	            confirmButtonText:'确定',
	            closeOnConfirm: false,
	            cancelButtonText:'取消'
	        },
	        function(isConfirm){
	            if(isConfirm){
	                window.obj = '';
	                $.ajax({
	                    url: pAuthUrl,
	                    data: 'status='+pStatus,
	                    dataType: "json",
	                    async:false,
	                    success: function (obj) {
	                        window.obj = obj;
	                    }
	                });

	                if(window.obj.status == 1){
	                    swal({title:"操作成功!", type:"success"},function(){
	                        location.href = pJumpUrl;
	                    });
	                }else{
	                    swal({title:window.obj.msg, type:"error"});
	                }
	            }
	        }
	    );
	}
	</script>
</body>
</html>